package com.zff.rental.entity.apartment;

import com.baomidou.mybatisplus.annotation.TableName;
import com.zff.rental.AppConstant;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 公寓管理员表
 *
 * @author HCY
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
@Entity
@IdClass(ApartmentManager.MId.class)
@Table(name = AppConstant.TABLE_NAME_APARTMENT_MANAGER)
@TableName(AppConstant.TABLE_NAME_APARTMENT_MANAGER)
public class ApartmentManager {
    /**
     * 公寓Id
     */
    @Id
    @Column(nullable = false)
    private Long apartmentId;

    /**
     * 用户Id
     */
    @Id
    @Column(nullable = false)
    private Long userId;

    /**
     * 是否为管理员 1:是，0:否
     */
    @Column(nullable = false)
    private Byte isAdmin;

    /**
     * 是否为管家 1:是，0:否
     */
    @Column(nullable = false)
    private Byte isButler;


    public boolean isAdmin() {
        return isAdmin == 1;
    }

    public boolean isButler() {
        return isButler == 1;
    }

    @EqualsAndHashCode
    @AllArgsConstructor
    @NoArgsConstructor
    public static class MId implements Serializable {
        private Long apartmentId;
        private Long userId;
    }
}
